/**
 * 项目名称:
 *
 * @Author: 夏国倩
 * @Date: 2023/9/22 11:07
 * @Copyright
 */
package Map;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class MapTest4 {
    public static void main(String[] args) {
        HashMap<String, Student> map = new HashMap<>();
        map.put("Jack", new Student("李明", '男'));
        map.put("Tom", new Student("王浩", '男'));
        map.put("Anda", new Student("安达", '女'));
        map.put("Lisa", new Student("丽萨", '女'));

        Set<Map.Entry<String, Student>> entrySet = map.entrySet();
        for (Map.Entry<String, Student> entry : entrySet) {
            String key = entry.getKey();
            Student value = entry.getValue();
            System.out.println(key + "对应的学员姓名是:" + value);
        }
        System.out.println("------------方法二-------------");
        Set<String> keySet = map.keySet();
        for (String s : keySet) {
            Student values = map.get(s);
            System.out.println(s + "对应的学员姓名是：" + values);
        }
    }
}
    class Student{
        private String name;
        private char sex;

        public Student(String name, char sex) {
            this.name = name;
            this.sex = sex;
        }
        @Override
        public String toString(){
            return name+";性别:"+sex;

    }
}
